package edu.sctu.nieyu.day20150606.trainsystem;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.HashMap;

/**
 * Created by user01 on 2015/6/6.
 */
public class JourneyTime {
    Passenger passenger0 = new PassengerData().passengerData().get(0);
    Passenger passenger1 = new PassengerData().passengerData().get(1);
    Passenger passenger2 = new PassengerData().passengerData().get(2);


    Calendar calendar1 = Calendar.getInstance();
    Calendar calendar2 = Calendar.getInstance();
    private Long totalTime1;
    private Long totalTime2;


    private String journeyTime;

    public void setJourneyTime(String journeyTime) {
        this.journeyTime = journeyTime;
    }

    public String getJourneyTime() {
        return journeyTime;
    }

    Calendar calendar = Calendar.getInstance();

    public void startTime(){
        calendar.set(2015,5,8,14,01);
        SimpleDateFormat simple = new SimpleDateFormat("yyyy-MM-dd hh:mm");
        String A = simple.format(calendar.getTime());
       setJourneyTime(A);
        System.out.println(passenger0.getName()+"的进站时间："+getJourneyTime());
    }

    public void endTime(){
        calendar.set(2015,5,8,17,01);
        TrainData trainData = new TrainData();
        HashMap<String ,Integer>map;
        map = trainData.hashMapData();
        int count = map.get(passenger0.getEnd())-map.get(passenger0.getStart())*2;
        SimpleDateFormat simple = new SimpleDateFormat("yyyy-MM-dd hh:mm");
        String end = simple.format(calendar.getTime());
        setJourneyTime(end);
        System.out.println(passenger0.getName()+"的出站时间为："+getJourneyTime());

    }


    public void time() {

        calendar1.set(2015, 5, 6, 13, 25);
        calendar2.set(2015, 5, 6, 14, 37);
        SimpleDateFormat simple = new SimpleDateFormat("yyyy-MM-dd hh:mm");
        String start = simple.format(calendar1.getTime());
        String end = simple.format(calendar2.getTime());
        passenger0.setStartTime(start);
        passenger0.setEndTime(end);
        System.out.println(passenger0.getName() + ":\n进站时间为：" + start + "\n出站时间为：" + end);
        totalTime1 = Math.abs(calendar2.getTime().getTime() - calendar1.getTime().getTime());
        System.out.println(passenger0.getName() + "的乘车总时间：");
        System.out.println(totalTime1 / (60 * 1000 * 60) + "时");






//        System.out.println(passenger1.getName() + "的乘车时间：");
//        calendar1.set(2015, 6, 7, 8, 49);
//        calendar2.set(2015, 6, 7, 10, 57);
//        totalTime2 = Math.abs(calendar2.getTime().getTime() - calendar1.getTime().getTime());
//        System.out.println(totalTime2 / (60 * 1000 * 60) + "时");


    }


}

